import 'package:flutter_admin/utils/utils.dart';

class ProductEquhisdata {

  String? id;
  String? devid;
  String? equcode;
  String? equname;
  String? dataname;
  String? datatype;
  String? datatypename;
  String? unitname;
  String? unitcode;
  String? histime;
  String? histimeStart;
  String? histimeEnd;
  String? timevalue;
  String? createUid;
  String? createDate;
  String? writeUid;
  String? writeDate;

  ProductEquhisdata({
    this.id,
    this.devid,
    this.equcode,
    this.equname,
    this.dataname,
    this.datatype,
    this.datatypename,
    this.unitname,
    this.unitcode,
    this.histime,
    this.histimeStart,
    this.histimeEnd,
    this.timevalue,
    this.createUid,
    this.createDate,
    this.writeUid,
    this.writeDate,
  });

  ProductEquhisdata copyWith({
    String? id,
    String? devid,
    String? equcode,
    String? equname,
    String? dataname,
    String? datatype,
    String? datatypename,
    String? unitname,
    String? unitcode,
    String? histime,
    String? timevalue,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new ProductEquhisdata(
      id: id ?? this.id,
      devid: devid ?? this.devid,
      equcode: equcode ?? this.equcode,
      equname: equname ?? this.equname,
      dataname: dataname ?? this.dataname,
      datatype: datatype ?? this.datatype,
      datatypename: datatypename ?? this.datatypename,
      unitname: unitname ?? this.unitname,
      unitcode: unitcode ?? this.unitcode,
      histime: histime ?? this.histime,
      timevalue: timevalue ?? this.timevalue,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''ProductEquhisdata{
      id: id,
      devid: devid,
      equcode: equcode,
      equname: equname,
      dataname: dataname,
      datatype: datatype,
      datatypename: datatypename,
      unitname: unitname,
      unitcode: unitcode,
      histime: histime,
      timevalue: timevalue,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) => identical(this, other) || (
      other is ProductEquhisdata &&
          runtimeType == other.runtimeType
          && id== other.id
          && devid== other.devid
          && equcode== other.equcode
          && equname== other.equname
          && dataname== other.dataname
          && datatype== other.datatype
          && datatypename== other.datatypename
          && unitname== other.unitname
          && unitcode== other.unitcode
          && histime== other.histime
          && timevalue== other.timevalue
          && createUid== other.createUid
          && createDate== other.createDate
          && writeUid== other.writeUid
          && writeDate== other.writeDate
   );


  factory ProductEquhisdata.fromMap(Map<String, dynamic> map) {
    return new ProductEquhisdata(
      id: map['id']!=false?map['id'].toString() as String?:"",
      devid: map['devid']!=false?map['devid'].toString() as String?:"",
      equcode: map['equcode']!=false?map['equcode'].toString() as String?:"",
      equname: map['equname']!=false?map['equname'].toString() as String?:"",
      dataname: map['dataname']!=false?map['dataname'].toString() as String?:"",
      datatype: map['datatype']!=false?map['datatype'].toString() as String?:"",
      datatypename: map['datatypename']!=false?map['datatypename'].toString() as String?:"",
      unitname: map['unitname']!=false?map['unitname'].toString() as String?:"",
      unitcode: map['unitcode']!=false?map['unitcode'].toString() as String?:"",
      histime: map['histime']!=false?map['histime'].toString() as String?:"",
      timevalue: map['timevalue']!=false?map['timevalue'].toString() as String?:"",
      createUid: map['create_uid']!=false?map['create_uid'].toString() as String?:"",
      createDate: map['create_date']!=false?Utils.timeUTC(map['create_date'].toString()) as String?:"",
      writeUid: map['write_uid']!=false?map['write_uid'].toString() as String?:"",
      writeDate: map['write_date']!=false?map['write_date'].toString() as String?:"",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'devid': this.devid,
      'equcode': this.equcode,
      'equname': this.equname,
      'dataname': this.dataname,
      'datatype': this.datatype,
      'datatypename': this.datatypename,
      'unitname': this.unitname,
      'unitcode': this.unitcode,
      'histime': this.histime,
      'timevalue': this.timevalue,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if(this.devid!=null&&this.devid!='')['devid','=',this.devid],
      if(this.unitname!=null&&this.unitname!='')['unitname','=',this.unitname],
      if(this.histimeStart!=null&&this.histimeStart!='')['histime','>=',this.histimeStart!],
      if(this.histimeEnd!=null&&this.histimeEnd!='')['histime','<=',this.histimeEnd!],
    ] as List;
    //if(list.length==0){
    //  list.add(['id','!=',null]);
    //}
    // ignore: unnecessary_cast
    return list;
  }

  List toChartDomainList() {
    List list = [
      // ['','','开关信号'],
      // ['unitname','=',"上电状态"],
      if(this.devid!=null&&this.devid!='')['devid','=',this.devid],
      if(this.unitname!=null&&this.unitname!='')['unitname','=',this.unitname],
      if(this.histimeStart!=null&&this.histimeStart!='')['histime','>=',this.histimeStart!],
      if(this.histimeEnd!=null&&this.histimeEnd!='')['histime','<=',this.histimeEnd!],
      ['chart']
    ] as List;
    //if(list.length==0){
    //  list.add(['id','!=',null]);
    //}
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'devid': this.devid,
      'equcode': this.equcode,
      'equname': this.equname,
      'dataname': this.dataname,
      'datatype': this.datatype,
      'datatypename': this.datatypename,
      'unitname': this.unitname,
      'unitcode': this.unitcode,
      'histime': this.histime,
      'timevalue': this.timevalue,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}